*** Create Figure 5 ***

********************************************************************************

clear 

** read in .dta file **
use "${clean}/who_counts_descriptives.dta", clear

* Show same general trend only keeping literate respondents

preserve

drop if YOB < 1945
drop if YOB > 1984
keep if MOB==0
keep if LIT==1
sum(count)
myers age, range(10 49)

graph bar, over(age, label(angle(45) labsize(tiny))) title("Age Heaping, 1944-1984, Unregistered & Literate") note("N=202K, Myers Blended Index: 3.68")
graph save "${output}/graphs/heaping_unreg_lit.gph", replace
graph export "${output}/graphs/heaping_unreg_lit.png", replace

restore

preserve
drop if YOB < 1945
drop if YOB > 1984
keep if MOB==1
keep if LIT==1
sum(count)
myers age, range(10 49)

graph bar, over(age, label(angle(45) labsize(tiny))) title("Age Heaping, 1944-1984, Registered & Literate") note("N=217K, Myers Blended Index: .9")
graph save "${output}/graphs/heaping_reg_lit.gph", replace
graph export "${output}/graphs/heaping_reg_lit.png", replace

grc1leg "${output}/graphs/heaping_reg_lit.gph" "${output}/graphs/heaping_unreg_lit.gph", title(Literate) legendfrom("${output}/graphs/heaping_unreg_lit.gph")
graph save "${output}/graphs/heaping_combined_lit.gph", replace
graph export "${output}/graphs/heaping_combined_lit.png", replace

restore

preserve

drop if YOB < 1945
drop if YOB > 1984
keep if MOB==1
keep if LIT==0
sum(count)
myers age, range(10 49)

graph bar, over(age, label(angle(45) labsize(tiny))) title("Age Heaping, 1944-1984, Registered & Illiterate") note("N=60K, Myers Blended Index: 2.85")
graph save "${output}/graphs/heaping_reg_illit.gph", replace
graph export "${output}/graphs/heaping_reg_illit.png", replace

restore

preserve

drop if YOB < 1945
drop if YOB > 1984
keep if MOB==0
keep if LIT==0
sum(count)
myers age, range(10 49)

graph bar, over(age, label(angle(45) labsize(tiny))) title("Age Heaping, 1944-1984, Unregistered & Illiterate") note("N=325K, Myers Blended Index: 8.1")
graph save "${output}/graphs/heaping_unreg_illit.gph", replace
graph export "${output}/graphs/heaping_unreg_illit.png", replace

restore

grc1leg "${output}/graphs/heaping_reg_illit.gph" "${output}/graphs/heaping_unreg_illit.gph", title(Illiterate) legendfrom("${output}/graphs/heaping_unreg_illit.gph")
graph save "${output}/graphs/heaping_combined_reg_lit.gph", replace
graph export "${output}/graphs/heaping_combined_reg_lit.png", replace

grc1leg "${output}/graphs/heaping_combined_lit.gph" "${output}/graphs/heaping_combined_reg_lit.gph", rows(2) legendfrom("${output}/graphs/heaping_combined_lit.gph")
graph save "${output}/graphs/Figure5.gph", replace
graph export "${output}/graphs/Figure5.png", replace

